<template>
	<view>
		<view v-if="buildworkercount != 0">
		<u-sticky><u-button type="primary" :plain="true" icon="https://project.gxrunxiang.com/cdn/change.png" @click="gotochange">修改</u-button></u-sticky>
		<u-collapse ref='coll' :value="['1','2','3']">
			<u-collapse-item name="1" title="基本信息" icon="https://project.gxrunxiang.com/cdn/my.png">
				<u-cell-group>
					<u-cell title="工号" :use-label-slot="true">
						<span slot="label" class="cell-label">{{buildworkerinfo.WorkNo}}</span>
					</u-cell>
					<u-cell title="姓名" :use-label-slot="true">
						<span slot="label" class="cell-label">{{buildworkerinfo.Name}}</span>
					</u-cell>
					<u-cell title="队长" :use-label-slot="true">
						<span slot="label" class="cell-label">{{buildworkerinfo.WorkTeam}}</span>
					</u-cell>
					<u-cell title="劳务公司" :use-label-slot="true">
						<span slot="label" class="cell-label">{{buildworkerinfo.WorkCompany}}</span>
					</u-cell>
					<u-cell title="证件类型" :use-label-slot="true">
						<span slot="label" class="cell-label">{{buildworkerinfo.IdCardType}}</span>
					</u-cell>
					<u-cell title="证件号" :use-label-slot="true">
						<span slot="label" class="cell-label">{{buildworkerinfo.IdCardNo}}</span>
					</u-cell>
					<u-cell title="国籍" :use-label-slot="true">
						<span slot="label" class="cell-label">{{buildworkerinfo.Country}}</span>
					</u-cell>
					<u-cell title="性别" :use-label-slot="true">
						<span slot="label" class="cell-label">{{buildworkerinfo.Sex}}</span>
					</u-cell>
					<u-cell title="手机号" :use-label-slot="true">
						<span slot="label" class="cell-label">{{buildworkerinfo.Cellphone}}</span>
					</u-cell>
					<u-cell title="银行卡号" :use-label-slot="true">
						<span slot="label" class="cell-label">{{buildworkerinfo.BankCard}}</span>
					</u-cell>
					<u-cell title="出生日期" :use-label-slot="true">
						<span slot="label" class="cell-label">{{buildworkerinfo.Birthday}}</span>
					</u-cell>
					<u-cell title="在职状态" :use-label-slot="true">
						<span slot="label" class="cell-label">{{buildworkerinfo.WorkStatus}}</span>
					</u-cell>
				</u-cell-group>
			</u-collapse-item>
			<u-collapse-item name="2" title="其他信息" icon="info-circle">
				<u-cell-group>
					<u-cell title="入职时间" :use-label-slot="true">
						<span slot="label" class="cell-label">{{buildworkerinfo.InTime ? buildworkerinfo.InTime : ""}}</span>
					</u-cell>
					<u-cell title="离职时间" :use-label-slot="true">
						<span slot="label" class="cell-label">{{buildworkerinfo.LeaveTime ? buildworkerinfo.LeaveTime : ""}}</span>
					</u-cell>
					<u-cell title="劳动合同是否签订" :use-label-slot="true">
						<span slot="label" class="cell-label">{{buildworkerinfo.IsContract ? '是' : '否'}}</span>
					</u-cell>
					<u-cell title="三级教育培训是否签订" :use-label-slot="true">
						<span slot="label" class="cell-label">{{buildworkerinfo.IsLv3Train ? '是' : '否'}}</span>
					</u-cell>
					<u-cell title="保密协议是否签订" :use-label-slot="true">
						<span slot="label" class="cell-label">{{buildworkerinfo.IsSecrecy ? '是' : '否'}}</span>
					</u-cell>
					<u-cell title="队长协议是否签订" :use-label-slot="true">
						<span slot="label" class="cell-label">{{buildworkerinfo.IsCaptainContract ? '是' : '否'}}</span>
					</u-cell>
					<u-cell title="安全交底是否签订" :use-label-slot="true">
						<span slot="label" class="cell-label">{{buildworkerinfo.IsSafe ? '是' : '否'}}</span>
					</u-cell>
					<u-cell title="是否购买保险" :use-label-slot="true">
						<span slot="label" class="cell-label">{{buildworkerinfo.IsInsure ? '是' : '否'}}</span>
					</u-cell>
					<u-cell title="保险单号" :use-label-slot="true">
						<span slot="label" class="cell-label">{{buildworkerinfo.InsureNo}}</span>
					</u-cell>
					<u-cell title="保险有效期" :use-label-slot="true">
						<span slot="label" class="cell-label">{{buildworkerinfo.InsureTime ? buildworkerinfo.InsureTime : ""}}</span>
					</u-cell>
					<u-cell title="高处作业证有效期" :use-label-slot="true">
						<span slot="label" class="cell-label">{{buildworkerinfo.HighCardTime ? buildworkerinfo.HighCardTime : ""}}</span>
					</u-cell>
					<u-cell title="电工证有效期" :use-label-slot="true">
						<span slot="label" class="cell-label">{{buildworkerinfo.EleCardTime ? buildworkerinfo.EleCardTime : ""}}</span>
					</u-cell>
					<u-cell title="备案时间" :use-label-slot="true">
						<span slot="label" class="cell-label">{{buildworkerinfo.RecordTime ? buildworkerinfo.RecordTime : ""}}</span>
					</u-cell>
					<u-cell title="备注" :use-label-slot="true">
						<span slot="label" class="cell-label">{{buildworkerinfo.Remark}}</span>
					</u-cell>
				</u-cell-group>
			</u-collapse-item>
			<u-collapse-item name="3" title="身份证" icon="https://project.gxrunxiang.com/cdn/image.png">
				<u-album :urls="imagesurls1"></u-album>
			</u-collapse-item>
			<u-collapse-item name="3" title="高处作业证" icon="https://project.gxrunxiang.com/cdn/image.png">
				<u-album :urls="imagesurls2"></u-album>
			</u-collapse-item>
			<u-collapse-item name="3" title="电工证" icon="https://project.gxrunxiang.com/cdn/image.png">
				<u-album :urls="imagesurls3"></u-album>
			</u-collapse-item>
			<u-collapse-item name="3" title="其他" icon="https://project.gxrunxiang.com/cdn/image.png">
				<u-album :urls="imagesurls4"></u-album>
			</u-collapse-item>
		</u-collapse>
		</view>
		<u-empty
		        mode="data"
		        icon="https://project.gxrunxiang.com/cdn/list.png"
				v-if="buildworkercount == 0"
		>
		</u-empty>
	</view>
</template>
<script>
	import {
		baseUrl
	} from '@/common/config.js'
	import {
		mapGetters
	} from 'vuex'

	import {
		getworkerslist,
		getfilebyoutid
	} from '@/common/api.js'
	export default {
		data() {
			return {
				pageIndex: 1, //当前页数
				pageSize: 1, //页数大小
				buildworkerinfo: [],
				user: {},
				imagesurls1: [],
				imagesurls2: [],
				imagesurls3: [],
				imagesurls4: [],
				workerName: "",
				buildworkercount: ""
			}
		},
		onLoad(option) {
			this.user = JSON.parse(uni.getStorageSync("$userinfo"))
			this.workerName=option.name
			this.getlist()	
		},
		methods: {
			async getlist() {
				// let querytype = this.$route.query.querytype
				let para = {
					Parameters: [],
				}
				para.Parameters.push({
					FieldName: "Name",
					ConditionalType: "Like",
					FieldValue:  this.workerName || this.user.Name
					// FieldValue: "欧阳科"

				})
				para.OrderBys = ['CreateTime desc']
				para.pageSize = this.pageSize
				para.pageIndex = this.pageIndex
				await getworkerslist(para).then(res => {
					this.buildworkerinfo = res.data[0]
					this.buildworkercount = res.count
				})
				this.imagesurls1 = []
				this.imagesurls2 = []
				this.imagesurls3 = []
				this.imagesurls4 = []
				getfilebyoutid(this.buildworkerinfo.Id).then(res => {
					for (var i = 0; i < res.length; i++) {
						if (res[i].MyType == '身份证') {
							this.imagesurls1.push(`${baseUrl}/SysFile/download?id=${res[i].Id}`)
						}
						if (res[i].MyType == '高处作业证') {
							this.imagesurls2.push(`${baseUrl}/SysFile/download?id=${res[i].Id}`)
						}
						if (res[i].MyType == '电工证') {
							this.imagesurls3.push(`${baseUrl}/SysFile/download?id=${res[i].Id}`)
						}
						if (res[i].MyType == '其他') {
							this.imagesurls4.push(`${baseUrl}/SysFile/download?id=${res[i].Id}`)
						}
					}
					setTimeout(() => {
							// console.log(this.$refs.coll)
							this.$refs.coll.init()
					
						},
						1000)
				})
			},
			gotochange(){
				if(this.workerName){
						uni.redirectTo({
						url: 'buildworkerchangeinfo?name=' + this.workerName
					})
				}else{
					uni.redirectTo({
						url: 'buildworkerchangeinfo'
					})
				}
				
			}
		}
	}
</script>
<style>
	.cell-label {
		margin-top: 10px;
		font-size: 14px;
		color: #909193;
	}
</style>